package com.xwaf.platform.system.auth.serviceimpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.plugins.Page;
import com.xwaf.platform.common.service.service.CrudService;
import com.xwaf.platform.common.utils.ThreadManager;
import com.xwaf.platform.system.api.entity.auth.OperateLog;
import com.xwaf.platform.system.api.service.auth.OperateLogService;
import com.xwaf.platform.system.auth.dao.OperateLogDao;
import com.xwaf.platform.system.auth.task.LogTask;

/**
 * 
 * <p>
 * 操作日志
 * <p>
 * 
 * @author 李聪 <br>
 * @email xwaf_love@yeah.net <br>
 * @since JDK 1.8<br>
 * @date 2019年12月27日 下午7:30:38 <br>
 * @see 无<br>
 *      Copyright (c) 2019, xwaf_love@yeah.net All Rights Reserved.<br>
 */
@Transactional(readOnly = true)
@Service("operateLogService")
public class OperateLogServiceImpl extends CrudService<OperateLogDao, OperateLog> implements OperateLogService {

	@Autowired
	private OperateLogDao operateLogDao;

	@Override
	public Page<OperateLog> selPageList(Page<OperateLog> page, OperateLog operateLog) {
		List<OperateLog> list = operateLogDao.selPageList(page, operateLog);
		page.setRecords(list);
		return page;
	}

	@Override
	public boolean insertLog(String module, String type, String ip, String content, String operater) {
		OperateLog operateLog = new OperateLog();
		operateLog.setModule(module);
		operateLog.setType(type);
		operateLog.setIp(ip);
		operateLog.setContent(content);
		operateLog.setCreateBy(operater);
		operateLog.setUpdateBy(operater);
		ThreadManager.execute(new LogTask(this, operateLog));
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return true;
	}

}
